package com.shardings.web;

import com.shardings.service.TestShardingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: LCG
 * @date: 2022-11-09 16:14:37
 * @description:
 **/
@RestController
public class TestShardingWeb {

    @Autowired
    private TestShardingService testShardingService;

    @RequestMapping("get123")
    public Object getUserList(){
        return testShardingService.insertToShardingDataBase();
    }

    @RequestMapping("get121")
    public Object userInsert(){
        testShardingService.insertUserDto();
        return "ok";
    }

    /**
     * @author: LCG
     * @date: 根据条件查询
     * @description:
     */
    @RequestMapping("get122/{userName}")
    public Object userInsert(@PathVariable String userName){
        return testShardingService.selectByName(userName);
    }


    /**
     * @author: LCG
     * @date: 根据条件查询
     * @description:
     */
    @RequestMapping("get124/{userName}/{buMen}/{id}")
    public Object userInsert(@PathVariable String userName,@PathVariable String buMen,@PathVariable Long id){
        return testShardingService.complexList(userName,buMen,id);
    }

    /**
     * @author: LCG
     * @date: 2022-11-16 13:56:51
     * @description:  强制路由
     */
    @RequestMapping("get125")
    public Object getHint(){
        return testShardingService.getListData();
    }

}
